package com.tengju.bff.interfaces.app.user;

import com.tengju.bff.interfaces.app.user.facade.ManageCentreDealerNewFacade;
import com.tengju.bff.interfaces.app.user.vo.ReportDealerDominationNewUserVO;
import com.tengju.bff.interfaces.app.user.vo.ReportDealerNewUserVO;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.servlet.ServletContextUtil;
import com.tengju.bff.interfaces.shared.servlet.RiskLevel;
import com.tengju.bff.interfaces.shared.servlet.UserServletContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

@Validated
@RestController
@Api(tags = "app经营中心")
@RequestMapping(value = "app/user/manage/centre")
@Slf4j
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class ManageCentreDealerNewController {

    private final ManageCentreDealerNewFacade manageCentreDealerNewFacade;


    @RiskLevel(key = "association")
    @ApiOperation(value = "社群", notes = "社群")
    @RequestMapping(value = "/association/new/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<ReportDealerNewUserVO>> getDealerNewUser(@NotNull @RequestParam(value = "month") Integer month) {
        UserServletContext userServletContext = ServletContextUtil.getServletContext();
        return ApiResponse.newSuccess(manageCentreDealerNewFacade.getDealerNewUser(userServletContext.needIdCode(),month));
    }

    @RiskLevel(key = "domination")
    @ApiOperation(value = "区域市场", notes = "区域市场")
    @RequestMapping(value = "/domination/new/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ApiResponse<List<ReportDealerDominationNewUserVO>> getDealerDominationNewUser(@NotNull @RequestParam(value = "year") Integer year) {
        UserServletContext userServletContext = ServletContextUtil.getServletContext();
        return ApiResponse.newSuccess(manageCentreDealerNewFacade.getDealerDominationNewUser(userServletContext.needIdCode(),year));
    }
}
